#[toml_cfg::toml_config]
pub struct Config {
    #[default("localhost")]
    mqtt_host: &'static str,
    #[default("")]
    mqtt_user: &'static str,
    #[default("")]
    mqtt_pass: &'static str,
    #[default("")]
    wifi_ssid: &'static str,
    #[default("")]
    wifi_psk: &'static str,
}

fn main() {
    // Check if the `cfg.toml` file exists and has been filled out.
    if !std::path::Path::new("cfg.toml").exists() {
        panic!("You need to create a `cfg.toml` file with your Wi-Fi credentials! Use `cfg.toml.example` as a template.");
    }

    // The constant `CONFIG` is auto-generated by `toml_config`.
    let app_config = CONFIG;
    if app_config.wifi_ssid == "FBI Surveillance Van" || app_config.wifi_psk == "hunter2" {
        panic!("You need to set the Wi-Fi credentials in `cfg.toml`!");
    }
    if app_config.mqtt_host == "yourpc.local"
        || app_config.mqtt_user == "horse"
        || app_config.mqtt_pass == "CorrectHorseBatteryStaple"
    {
        panic!("You need to set the MQTT credentials in `cfg.toml`!");
    }

    embuild::espidf::sysenv::output();
}
